using System.Configuration;
using System.Data;
using System.Data.SqlClient;

namespace Web.Step03
{
   public static class ProductService
   {
      public static DataTable GetProducts()
      {
         using (var conn = new SqlConnection(ConfigurationManager.ConnectionStrings["TheDatabaseConnectionString"].ConnectionString))
         using (var cmd = new SqlCommand("SELECT * FROM Product", conn))
         {
            conn.Open();

            var dt = new DataTable();
            dt.Load(cmd.ExecuteReader(CommandBehavior.CloseConnection));
            return dt;
         }
      }
   }
}